import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 引入全局样式--公共样式
import '@/assets/css/common.less'
// 1.导入axios
import axios from 'axios'

// 2.挂载到原型上
Vue.prototype.$http = axios

// 3.设置axios请求根路径
axios.defaults.baseURL = `http://127.0.0.1:8888/api/private/v1/`

// 把`Authorization`写入到token
axios.interceptors.request.use(config => {
  console.log(config)
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

// response拦截
axios.interceptors.response.use(config => {
  return config
})

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')